package com.airbnb.mvrx.sample

import com.airbnb.mvrx.sample.core.BaseFragment
import com.airbnb.mvrx.sample.core.simpleController
import com.airbnb.mvrx.sample.views.basicRow
import com.airbnb.mvrx.sample.views.marquee
import com.example.mvrxstudy.R

class MainFragment : BaseFragment() {

    override fun epoxyController() = simpleController {
        marquee {
            id("marquee")
            title("Welcome to MvRx")
            subtitle("Select a demo below")
        }

        basicRow {
            id("bookDetail")
            title("书籍详情")
            clickListener { _ ->
                navigateTo(R.id.actionBookDetailFragment)
            }
        }

        basicRow {
            id("hello_world")
            title("点读")
            clickListener { _ -> navigateTo(R.id.action_main_to_helloWorldFragment) }
        }

        basicRow {
            id("hello_world_epoxy")
            title("Hello World (Epoxy)")
            subtitle(demonstrates("Simple MvRx usage", "Epoxy integration"))
            clickListener { _ -> navigateTo(R.id.action_main_to_helloWorldEpoxyFragment) }
        }

    }

    private fun demonstrates(vararg items: String) =
            arrayOf("Demonstrates:", *items).joinToString("\n\t\t• ")
}